package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("employee")
public class EmployeeController {

    @Autowired
    private IEmployeeService iEmployeeService;

    @RequestMapping("add")
    public String add(EmployeeBean employeeBean, int deptId) {
        iEmployeeService.add(employeeBean, deptId);
        return "ok";
    }

    @RequestMapping("findByPage")
    public PageInfo<EmployeeBean> findByPage(int pageNo, String name, LocalDate startDate, LocalDate endDate) {
        return iEmployeeService.findByPage(pageNo, name, startDate, endDate);
    }

    @RequestMapping("del")
    public String del(int employeeId) {
        iEmployeeService.del(employeeId);
        return "ok";
    }

    @RequestMapping("findById")
    public EmployeeBean findById(int employeeId) {
        return iEmployeeService.findById(employeeId);
    }

    @RequestMapping("update")
    public String update(int employeeId, int deptId, int money) {
        iEmployeeService.update(employeeId, deptId, money);
        return "ok";
    }

}
